
//TODO a(65)
function a65(module, exports, a) {
    function i(e) {
        this.nodes = e, this.videoWidth = this.nodes.parentEl.width(), this.videoHeight = this.nodes.parentEl.height()
    }

    var s = a(3), r = a(23), n = (a(2), a(6)), o = a(21);
    s.extend(i, r);
    var l = {
        init: function () {
            this.playerData = this.manager.playerData, this.totalArr = {}, this.currentArr = {}, this.currentArrIndex = 0, this.curentIndex = 0, this.ulendArr = [], this.ulNum = 0, this.ulGap = 35, this.ulIndex = 0, this.isOn = !0, this.BarrageObj = {}, this.barrageGap = 30, this.stop = null, this.isgetData = !1, this.isChange = !1, this.laststate = "", this.lis = [], this.vol = 5, this.ulNumArray = [], this.sendBarrgeText = "", this.setInputStatus = null, this.expr = 604800, this.effectBarrageObj = {
                densityBr: 2,
                alphaBr: 100,
                banRoll: 1,
                banBottom: 1,
                banTop: 1
            }, this.div = this.nodes.parentEl.find(".hv_barrage")[0], this.manager.evt.on(o.EVENT.RESIZE, this.onResize, this), this.manager.evt.on("vjs_toggleBarrge", this.toggleBarrge, this), this.manager.evt.on("vjs_setBarrageState", this.toggleBarrge, this), this.manager.evt.on("vjs_sendBarrge", this.sendBarrage, this), this.manager.evt.on("vjs_pushBarrageData", this.sendPageBarrage, this), this.manager.evt.on("vjs_setEffectBarrage", this.setEffectBarrage, this);
            var e = (new Date).getTime();
            if (null != localStorage.getItem("barrageTime")) {
                var t = localStorage.getItem("barrageTime");
                (e - t) / 1e3 < this.expr ? (this.effectBarrageObj.alphaBr = localStorage.getItem("alphaBr"), this.effectBarrageObj.densityBr = localStorage.getItem("densityBr"), this.effectBarrageObj.banRoll = localStorage.getItem("banRoll"), this.effectBarrageObj.banBottom = localStorage.getItem("banBottom"), this.effectBarrageObj.banTop = localStorage.getItem("banTop"), this.isOn = localStorage.getItem("barrgeState")) : (localStorage.removeItem("barrageTime"), localStorage.removeItem("alphaBr"), localStorage.removeItem("densityBr"), localStorage.removeItem("banRoll"), localStorage.removeItem("banBottom"), localStorage.removeItem("banTop"), localStorage.removeItem("barrgeState"))
            }
            this.startListen(), this.manager.listener.on(o.BARRAGE_STATE, function (e, t) {
                this.isOn = localStorage.getItem("barrgeState") ? "false" != localStorage.getItem("barrgeState") : t
            }, this)
        }, startListen: function () {
            this.manager.listener.on(o.PLAY_STATE, function (e, t) {
                "init" == t ? (this.removeAllItem(), this.totalArr = {}, this.onResize(), this.currentArrIndex = 0, this.curentIndex = 0, this.ulNum = 0, this.ulIndex = 0, this.isChange = !1, this.setVol()) : "play" == t ? "seeking" == this.laststate || "ended" == this.laststate ? (this.removeAllItem(), this.getData()) : this.getTotalData() : "stop" == t ? this.removeAllItem() : "changeDefi" == t && this.removeAllItem(), this.laststate = t
            }, this)
        }, getData: function () {
            this.currentArrIndex = Math.floor(this.manager.curVideo.getCurrentTime() / 300), this.totalArr[this.currentArrIndex] ? (this.curentIndex = 0,
                    this.currentArr = this.totalArr[this.currentArrIndex], this.stop && (clearInterval(this.stop), this.stop = null), this.stop = setInterval(s.bind(this.updateBarrage, this), 100)) : this.getTotalData()
        }, toggleBarrge: function (e) {
            this.isOn = e.args[0], e.args[0] ? this.getData() : this.removeAllItem(), localStorage.setItem("barrgeState", this.isOn)
        }, setEffectBarrage: function (e) {
            this.effectBarrageObj = e.args[0], this.setBanBarrage(), this.setBarrgeAlpha(), this.setDensityBr();
            var t = (new Date).getTime();
            localStorage.setItem("barrageTime", t), localStorage.setItem("alphaBr", this.effectBarrageObj.alphaBr), localStorage.setItem("densityBr", this.effectBarrageObj.densityBr), localStorage.setItem("banRoll", this.effectBarrageObj.banRoll), localStorage.setItem("banBottom", this.effectBarrageObj.banBottom), localStorage.setItem("banTop", this.effectBarrageObj.banTop)
        }, setBanBarrage: function () {
            var e = document.getElementsByClassName("hv_barrage")[0];
            if (2 == this.effectBarrageObj.banRoll) {
                for (var t = e.getElementsByClassName("roll"), a = t.length - 1; a >= 0; a--)t[a].parentNode.removeChild(t[a]);
                for (var i = 0; i < this.ulendArr.length; i++)this.ulendArr[i] = null
            }
            if (2 == this.effectBarrageObj.banBottom)for (var t = e.getElementsByClassName("bottom"), a = t.length - 1; a >= 0; a--)t[a].parentNode.removeChild(t[a]);
            if (2 == this.effectBarrageObj.banTop)for (var t = e.getElementsByClassName("top"), a = t.length - 1; a >= 0; a--)t[a].parentNode.removeChild(t[a])
        }, setDensityBr: function () {
            this.setUlNum(), this.effectBarrageObj.densityBr == -1 ? this.barrageGap = 1 : 2 == this.effectBarrageObj.densityBr ? this.barrageGap = 30 : 1 == this.effectBarrageObj.densityBr ? (this.ulNum = Math.floor(this.ulNum / 2), this.removeBarrge(this.ulNum)) : 0 == this.effectBarrageObj.densityBr && (this.ulNum = Math.floor(this.ulNum / 4), this.removeBarrge(this.ulNum))
        }, removeBarrge: function (e) {
            this.barrageGap = 30;
            for (var t = document.getElementsByClassName("hv_barrage")[0], a = t.getElementsByTagName("ul"), i = e; i < a.length; i++)a[i].innerHTML = ""
        }, setBarrgeAlpha: function () {
            var e = document.getElementsByClassName("hv_barrage")[0];
            if (e)for (var t = e.getElementsByTagName("li"), a = 0; a < t.length; a++)t[a].style.opacity = this.effectBarrageObj.alphaBr / 100
        }, sendPageBarrage: function (e) {
            this.BarrageObj = e.args[0]
        }, sendBarrage: function (e) {
            this.sendTextTemp = e.args[0], this.setInputStatus = e.args[1];
            var t = this.manager.listener.get(o.USER_INFO);
            if (t) {
                var a = "http://hd.my.le.com/danmu/add", i = {
                    vid: this.playerData.vinfo.vid,
                    pid: this.playerData.vinfo.pid,
                    cid: this.playerData.vinfo.cid,
                    start: this.manager.curVideo.getCurrentTime(),
                    isIdentify: 1,
                    txt: e.args[0],
                    color: "FFFFFF",
                    font: "m",
                    type: "txt",
                    position: "4"
                };
                this.jsonp = s.getJSON({
                    url: a,
                    data: i,
                    success: s.bind(this.onsendSuccess, this),
                    fail: s.bind(this.onsendFail, this)
                })
            } else this.manager.evt.trigger(o.EVENT.PLAYER_CALLBACK, "openLoginDialog")
        }, onsendSuccess: function (e) {
            this.jsonp = null;
            405 == e.code ? (this.setInputStatus("用户未实名认证"), this.manager.evt.trigger(o.EVENT.PLAYER_CALLBACK, "openAuthentication")) : 403 == e.code ? (this.setInputStatus("用户未登录"), this.manager.evt.trigger(o.EVENT.PLAYER_CALLBACK, "openLoginDialog")) : 401 == e.code ? this.setInputStatus("含有敏感词") : 402 == e.code ? this.setInputStatus("发布太频繁，喝口水吧") : 404 == e.code ? this.setInputStatus("用户被禁言") : 406 == e.code ? this.setInputStatus("没有ip") : 500 == e.code ? this.setInputStatus("失败") : (this.BarrageObj.txt = this.sendTextTemp, this.BarrageObj.position = "4", this.BarrageObj.font = "m", this.BarrageObj.color = "FFFFFF", this.setInputStatus("success"))
        }, onsendFail: function () {
            this.jsonp = null
        }, onResize: function () {
            this.removeAllItem(), this.videoWidth = this.nodes.parentEl.width(), this.videoHeight = this.nodes.parentEl.height(), this.getTotalData(), this.setVol()
        }, setVol: function () {
            this.vol = this.videoWidth > 640 ? 8 : 5
        }, getTotalData: function () {
            var e = "http://hd.my.le.com/danmu/list", t = {
                vid: this.playerData.vinfo.vid,
                start: this.manager.curVideo.getCurrentTime() + 5,
                amount: 2e3
            };
            this.jsonp = s.getJSON({
                url: e,
                data: t,
                success: s.bind(this.onSuccess, this),
                fail: s.bind(this.onFail, this)
            })
        }, onSuccess: function (e) {
            this.jsonp = null, 200 == e.code && (this.parseBarrageVO(e), this.showBarrage())
        }, onFail: function () {
            this.jsonp = null
        }, parseBarrageVO: function (e) {
            this.currentArrIndex = Math.floor((this.manager.curVideo.getCurrentTime() + 5) / 300), this.curentIndex = 0, this.totalArr[this.currentArrIndex] = e.data.list, this.totalArr[this.currentArrIndex].sort(s.compare("start")), this.currentArr = this.totalArr[this.currentArrIndex];
            for (var t = 0; t < this.totalArr.length; t++)if (this.currentArr[t].start >= this.manager.curVideo.getCurrentTime()) {
                this.curentIndex = t;
                break
            }
            this.stop && (clearInterval(this.stop), this.stop = null), this.stop = setInterval(s.bind(this.updateBarrage, this), 100), this.isgetData = !1
        }, showBarrage: function () {
            if (!this.isChange) {
                var e = "";
                this.setUlNum(), this.ulNumArray = [];
                for (var t = 0; t < this.ulNum; t++)this.ulNumArray.push(0), e += '<ul style="position:relative;top:' + (t * this.ulGap + 30) + 'px"></ul>';
                this.div.innerHTML = e, this.div.style.top = "0px", this.isChange = !1, this.setDensityBr()
            }
        }, setUlNum: function () {
            this.ulNum = Math.floor((this.videoHeight - 80) / 35), this.ulGap = 35, this.ulNum > 10 && (this.ulNum = 10, this.ulGap = Math.floor((this.videoHeight - 80) / 10))
        }, updateBarrage: function () {
            if ("pause" != this.laststate && this.isOn && !this.manager.listener.get(o.IS_AD)) {
                if (this.currentArr) {
                    for (var e = this.curentIndex; e < this.currentArr.length; e++) {
                        if (this.currentArr[e].start > this.manager.curVideo.getCurrentTime()) {
                            "string" == typeof this.BarrageObj.txt && this.insertItem(0);
                            break
                        }
                        if (!(this.currentArr[e].start < this.manager.curVideo.getCurrentTime() - 3)) {
                            for (var t = 0; t <= this.ulNum; t++)if (!this.ulendArr[t] || (this.ulendArr[t].offsetWidth + this.videoWidth) * this.ulendArr[t].interval / (1e3 * this.vol) - this.ulendArr[t].offsetWidth > this.barrageGap) {
                                this.ulIndex = t;
                                break
                            }
                            this.ulIndex < this.ulNum && this.insertItem(this.ulIndex);
                            break
                        }
                        this.curentIndex++
                    }
                    0 == this.currentArr.length && "string" == typeof this.BarrageObj.txt && this.insertItem(0)
                }
                for (var t = 0; t < this.ulendArr.length; t++)this.ulendArr[t] && (this.ulendArr[t].interval += 100)
            }
            if (this.currentArr && !this.isgetData) {
                this.currentArr.length;
                this.manager.curVideo.getCurrentTime() >= 300 * this.currentArrIndex + 300 && (this.totalArr[this.currentArrIndex + 1] ? (this.currentArrIndex++, this.currentArr = this.totalArr[this.currentArrIndex], this.curentIndex = 0) : (this.isChange = !0, this.isgetData = !0, this.getTotalData()))
            }
        }, setColor: function (e) {
            return 6 != e.length || "" == e || "000000" == e ? "FFFFFF" : e
        }, mapFontsize: function (e) {
            return "l" == e ? "24px" : "m" == e ? "20px" : "s" == e ? "18px" : "20px"
        }, insertItem: function (e) {
            var t, a = this, i = document.createElement("li"), s = {};
            if (s = this.currentArr[this.curentIndex], i.style["float"] = "left", i.style.position = "absolute", i.style.lineHeight = "25px", i.style.whiteSpace = "nowrap", i.style.listStyle = "none", i.style.opacity = this.effectBarrageObj.alphaBr / 100, i.style.textShadow = "1px 1px 2px #000000", s && (i.style.color = "#" + this.setColor(s.color), i.style.fontSize = this.mapFontsize(s.font), i.innerText = s.txt, i.position = s.position), "string" == typeof this.BarrageObj.txt ? (i.style.fontSize = this.mapFontsize(this.BarrageObj.font), i.style.color = "#" + this.BarrageObj.color, i.innerText = this.BarrageObj.txt, i.position = this.BarrageObj.position) : this.curentIndex++, i.style.padding = "0rem 1rem", 1 == i.position) {
                if (1 == parseInt(this.effectBarrageObj.banTop) || "string" == typeof this.BarrageObj.txt) {
                    for (var r = -1, o = 0; o < this.ulNumArray.length; o++)if (0 == this.ulNumArray[o]) {
                        r = o, this.ulNumArray[o] = 1;
                        break
                    }
                    r > -1 && (t = this.div.childNodes[r], t && t.appendChild(i), i.style.left = (this.videoWidth - i.offsetWidth) / 2 + "px", i.index = r, i.className = "top", setTimeout(function () {
                        i.parentNode && i.parentNode.removeChild(i), a.ulNumArray[i.index] = 0
                    }, 4e3))
                }
            } else if (3 == i.position) {
                if (1 == parseInt(this.effectBarrageObj.banBottom) || "string" == typeof this.BarrageObj.txt) {
                    for (var l = -1, d = this.ulNumArray.length - 1; d >= 0; d--)if (0 == this.ulNumArray[d]) {
                        l = d, this.ulNumArray[d] = 1;
                        break
                    }
                    l > -1 && (t = this.div.childNodes[l], t && t.appendChild(i), i.style.left = (this.videoWidth - i.offsetWidth) / 2 + "px", i.index = l, i.className = "bottom", setTimeout(function () {
                        i.parentNode && i.parentNode.removeChild(i), a.ulNumArray[i.index] = 0
                    }, 4e3))
                }
            } else 1 != parseInt(this.effectBarrageObj.banRoll) && "string" != typeof this.BarrageObj.txt || (t = this.div.childNodes[e], t && t.appendChild(i), this.ulendArr[e] = i, this.ulendArr[e].interval = 0, i.style.transitionTimingFunction = "linear", i.className = "roll", n(i).setStyle("-webkit-transform", "translateX(" + this.videoWidth + "px)"), n(i).setStyle("-moz-transform", "translateX(" + this.videoWidth + "px)"), n(i).setStyle("-ms-transform", "translateX(" + this.videoWidth + "px)"), n(i).setStyle("-o-transform", "translateX(" + this.videoWidth + "px)"), n(i).setStyle("transform", "translateX(" + this.videoWidth + "px)"), i.offsetWidth, n(i).setStyle("-webkit-transitionDuration", this.vol + "s"), n(i).setStyle("-webkit-transitionTimingFunction", "linear"), n(i).setStyle("-webkit-transform", "translateX(" + -i.offsetWidth + "px)"), n(i).setStyle("transitionDuration", this.vol + "s"), n(i).setStyle("transitionTimingFunction", "linear"), n(i).setStyle("transform", "translateX(" + -i.offsetWidth + "px)"), i.addEventListener("webkitTransitionEnd", function () {
                i && i.parentNode.removeChild(i)
            }, !1));
            this.BarrageObj = {}
        }, removeAllItem: function () {
            var e = document.getElementsByClassName("hv_barrage")[0];
            if (e) {
                for (var t = e.getElementsByTagName("li"), a = t.length - 1; a >= 0; a--)t[a].parentNode.removeChild(t[a]);
                for (var i = 0; i < this.ulendArr.length; i++)this.ulendArr[i] = null
            }
            this.currentArrIndex = Math.floor((this.manager.curVideo.getCurrentTime() + 5) / 300), this.curentIndex = 0, this.stop && (clearInterval(this.stop), this.stop = null)
        }
    };
    s.merge(i.prototype, l), module.exports = i
}
